import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
// 首页
import Index from '@/view/index/index.vue';
import Resume from '@/view/resume/resume.vue';

const router = new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    { path: '/', redirect: '/index' },
    { path: '/index', name: 'index', component: Index },
    { path: '/resume', name: 'resume', component: Resume },
  ]
});

// 解决导航栏中的Vue-router在3.0版本以上重点菜单报错问题
const originalPush = Router.prototype.push;
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err);
};

router.beforeEach(async (to, from, next) => {
  next();
});
router.afterEach(() => {
  window.scrollTo(0, 0);
});
export default router;

// export const subRouter = _subRouter;
